package com.linefly.online_car.Custom;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.linefly.online_car.R;


/**
 * Created by liheng on 2018/11/16.
 */

public class Custom_Dialog_Loading extends Dialog {

    private Context context;
    private ImageView img_loading;

    public Custom_Dialog_Loading(Context context1){

        super(context1, R.style.pagerDialog);
        context = context1;

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().getAttributes().gravity = Gravity.CENTER;
        setContentView(R.layout.item_loading);


        //按空白处不能取消动画
        setCanceledOnTouchOutside(false);
        setCancelable(false);

        Window dialogWindow = getWindow();
                 WindowManager.LayoutParams lp = dialogWindow.getAttributes();
                 DisplayMetrics d = context.getResources().getDisplayMetrics(); // 获取屏幕宽、高用

                 lp.width = (int) (d.widthPixels * 0.5); // 宽度度设置为屏幕的0.5
                 lp.height = (int) (d.widthPixels * 0.4); // 高度设置为宽度的0.8

                 dialogWindow.setAttributes(lp);

        img_loading = (ImageView)findViewById(R.id.loading);
        Glide.with(context).load(R.mipmap.loading).into(img_loading);
//        //初始化界面控件
//        initView();
//        //初始化界面数据
//        initData();
//        //初始化界面控件的事件
//        initEvent();

    }

}

